//
//  MaskView.m
//  Camera
//
//  Created by gml on 2018/9/29.
//  Copyright © 2018年 gml. All rights reserved.
//

#import "MaskView.h"
#import <AVFoundation/AVFoundation.h>

@interface MaskView()

@end

@implementation MaskView

- (instancetype)init
{
    if (self = [super init]) {
        [self setupViews];
    }
    return self;
}
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        [self setupViews];
    }
    return self;
}
-(void)setupViews
{
    UIView *maskView = [[UIView alloc] initWithFrame:self.frame];
    maskView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
    [self addSubview:maskView];
    
    UIImage *maskImage = [UIImage imageNamed:@"左后"];
    CALayer *layer = [[CALayer alloc] init];
    layer.frame = CGRectMake(0, 0, maskImage.size.width, maskImage.size.height);
    layer.contents = (__bridge id _Nullable)(maskImage.CGImage);
    layer.position = self.center;
    maskView.layer.mask = layer;
}
@end
